<template>
  <div style="margin:35px 0 20px 0">
    <div>
      <van-card
        num="1"
        :price="ordeyList.price"
        :desc="ordeyList.timer"
        :title="ordeyList.title1"
        :thumb="ordeyList.haibao"
      />
    </div>
    <van-address-edit
      save-button-text="立即下单"
      :area-list="areaList"
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
    />
  </div>
</template>

<script>
import { areaList } from "@vant/area-data";
import { Toast } from "vant";
// 获取用户名
import session from "../../http/session";
export default {
  name: "WorkspaceJsonOrdershow",

  data() {
    return {
      areaList,
      searchResult: [],
      ordeyList: [],
    };
  },
  methods: {
    onSave(e) {
      // 获取当前登录用户名
      session().then((res) => {
        // console.log(res.data.data[0].uname);
        this.$http
          .post("shoeCollect", {
            username: res.data.data[0].uname,
            name: e.name,
            address: `${e.province}/${e.city}/${e.county}`,
            iphone: e.tel,
            image: this.ordeyList.haibao,
            title: this.ordeyList.title1,
            timer: this.ordeyList.timer,
            price: this.ordeyList.price,
            ids: this.ordeyList.ids,
          })
          .then((result) => {
            if(result.data.coded==200){
              Toast.success('订单已经生成')
              window.location.href = "weixin://";
            }
            // console.log(result);
          }).catch(err=>{
            Toast.fail('订单生成失败')
            // console.log(err);
          })
      });
      // console.log(e);
    },
  },
  mounted() {
    let ids = this.$route.query.ids;
    this.$http
      .get("/yanchuDetil", {
        params: {
          ids,
        },
      })
      .then((res) => {
        console.log(res);
        this.ordeyList = res.data.data[0];
      });
  },
};
</script>

<style lang="scss" scoped>
</style>